#include<fstream.h>
#include<stdlib.h> 

void phase(char *ef,char *nf, int st_row,int d)
{
	fstream file_ef(ef,ios::in);
	float sum1,sum2,sum3,sum4,sum5,sum6;	
	sum1=sum2=sum3=sum4=sum5=sum6=0;
	long int counter=0;
	int row;
	char str[120];

	 while(file_ef >> str)
        {
		counter++;
		
		
		row =(counter+5)/6;
		if((row-st_row)%d!=0 )
			continue;
							
		
		switch(counter%6)
		{
		case 1:
			sum1+=atof(str);
			cout<<endl;
			break;
		case 2:
			sum2+=atof(str);
			break;
		case 3:
			sum3+=atof(str);
			break;
		case 4:
			sum4+=atof(str);
			break;
		case 5:
			sum5+=atof(str);
			break;
		case 0:
			sum6+=atof(str);

			break;
		default:
			break;
		}
		cout<<str<<"\t"; 
	}	
	
        file_ef.close();
};

int main()
{
	char str[2000];/*
        fstream file_op("wj1.vel",ios::in);
	int counter=0;	

	float sum1,sum2,sum3,sum4,sum5,sum6;	
	sum1=sum2=sum3=sum4=sum5=sum6=0;

        while(file_op >> str)
        {
		counter++;
		switch(counter%6)
		{
		case 1:
			sum1+=atof(str);
			cout<<endl;
			break;
		case 2:
			sum2+=atof(str);
			break;
		case 3:
			sum3+=atof(str);
			break;
		case 4:
			sum4+=atof(str);
			break;
		case 5:
			sum5+=atof(str);
			break;
		case 0:
			sum6+=atof(str);

			break;
		default:
			break;
		}
		
		
			//cout << str <<"\t";
		
		
	}
	cout<<counter;
	cout<<endl<<sum1<<endl;
	cout<<endl<<sum2<<endl;
	cout<<endl<<sum3<<endl;
	cout<<endl<<sum4<<endl;
	cout<<endl<<sum5<<endl;
	cout<<endl<<sum6<<endl;

	cout<<"average 4  :  "<<sum4/12000.<<endl;
	cout<<"average 5  :  "<<sum5/12000.<<endl;
	cout<<"average 6  :  "<<sum6/12000.<<endl;
	
 
        file_op.close();*/
	
	phase("wj1.vel","jasdkljf",1,10000);

        return 0;
    }
